<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>按键修饰符</title>
    <script src="./lib/vue-2.6.12.js"></script>
</head>
<body>
    <div id="app">
        <input type="text" @keyup.enter="submit" @keyup.esc="clearInput">
    </div>

    <script>
        const vm=new Vue({
            el:"#app",
            data:{},
            methods: {
                // 获取文本框最新的值
                submit(e){
                    // e.target表示获取执行该函数的html标签对象
                    e.target.value="按下了enter键";
                    console.log('按下了enter键');
                },
                // 清空文本框的值
                clearInput(e){
                    e.target.value='';
                }
            },
        })
    </script>
</body>
</html>